package system

import (
	"context"

	"go_admin/api/system/v1"
	"go_admin/internal/service"
)

func (c *ControllerV1) GetDict(ctx context.Context, req *v1.GetDictReq) (res *v1.GetDictRes, err error) {
	res, err = service.SysDictData().GetDictWithDataByType(ctx, req.DictType, req.DefaultValue)
	return
}
func (c *ControllerV1) DictDataList(ctx context.Context, req *v1.DictDataListReq) (res *v1.DictDataListRes, err error) {
	res, err = service.SysDictData().List(ctx, req)
	return
}
func (c *ControllerV1) DictDataAdd(ctx context.Context, req *v1.DictDataAddReq) (res *v1.DictDataAddRes, err error) {
	err = service.SysDictData().Add(ctx, req, service.Context().GetUserId(ctx))
	return
}
func (c *ControllerV1) DictDataGet(ctx context.Context, req *v1.DictDataGetReq) (res *v1.DictDataGetRes, err error) {
	res, err = service.SysDictData().Get(ctx, req.DictCode)
	return
}
func (c *ControllerV1) DictDataEdit(ctx context.Context, req *v1.DictDataEditReq) (res *v1.DictDataEditRes, err error) {
	err = service.SysDictData().Edit(ctx, req, service.Context().GetUserId(ctx))
	return
}
func (c *ControllerV1) DictDataDelete(ctx context.Context, req *v1.DictDataDeleteReq) (res *v1.DictDataDeleteRes, err error) {
	err = service.SysDictData().Delete(ctx, req.Ids)
	return
}
